﻿using System.ComponentModel;
using RaytracerLib;
using RaytracerLib.MathLib;

namespace Raytracer.PropertyGridDecorators
{
    public class OrientedElementProperties : SceneActorProperties
    {
        private OrientedElement m_oriented_element;

        public OrientedElementProperties(OrientedElement a_oriented_element) :
            base(a_oriented_element)
        {
            m_oriented_element = a_oriented_element;
        }

        [Category(Categories.ORIENTATION)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties Forward
        {
            get
            {
                return new Vector3Properties(
                    () => m_oriented_element.Forward,
                    (v) => m_oriented_element.Forward = v);
            }
            set
            {
                m_oriented_element.Forward = value.ToVector3();
            }
        }

        [Category(Categories.ORIENTATION)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties Up
        {
            get
            {
                return new Vector3Properties(
                    () => m_oriented_element.Up,
                    (v) => m_oriented_element.Up = v);
            }
            set
            {
                m_oriented_element.Up = value.ToVector3();
            }
        }

        [Category(Categories.ORIENTATION)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties Right
        {
            get
            {
                return new Vector3Properties(
                    () => m_oriented_element.Right,
                    (v) => m_oriented_element.Right = v);
            }
            set
            {
                m_oriented_element.Right = value.ToVector3();
            }
        }

        [Category(Categories.ORIENTATION)]
        [TypeConverter(typeof(Vector3Converter))]
        public Vector3Properties Scale
        {
            get
            {
                return new Vector3Properties(
                    () => m_oriented_element.Scale,
                    (v) => m_oriented_element.Scale = v);
            }
            set
            {
                m_oriented_element.Scale = value.ToVector3();
            }
        }
    }
}